Android Accessibility by Tutorials by By Victoria Gonda

Android Accessibility by Tutorials by By Victoria Gonda

Author:By Victoria Gonda
Language: eng
Format: epub
Publisher: Ray Wenderlich


Next up, you’ll set up Taco Tuesday to support dark mode.

Adding support for dark mode

Lucky for you, Taco Tuesday uses semantic names for all the colors, so you only need to provide colors for the dark theme and enable it.

Start by creating a file to hold your dark theme colors:

In Android Studio’s Project pane, select the Project tab.

Then create colors.xml in app/src/main/res/values-night.

Note the values-night part of the file path, which specifies that this is for the “night” configuration. If the project doesn’t contain the values-night directory, create it.

Add this content to the file:

<?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#52a871</color> <color name="colorAccent">#FFe6782a</color> </resources>

With this, you’re overriding the primary and accent colors.

These colors already meet accessibility guidelines for color contrast. The Material theme handles all the other colors.

Next, you’ll instruct the theme to allow dark mode.

Open styles.xml and find the AppTheme style.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.